-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refacto provider and add Sources #798
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks better than the current state IMHO.
Some remarks after a quick review :
layer.source || layer
looks odd, is it temporary ? can't we get rid of it ?- converts and parsers are 2 different things (eg: WMTS source -> Geojson parser -> Mesh converter)
I however feel that tiledCRS version of extents should be an implementation detail of quadtree-based sources and that other parts of itowns should only handle extents as a (BBox3 + CRS).
Likewise instead of relative pitches / offsetscales, we could use absolute coordinates (BBox2 + CRS) for textures so that downscaling a texture would be a noop and uvs in the shader would be well defined coordinates with a proper crs instead of normalized coordinates.
src/Core/TileMesh.js
Outdated
@@ -205,8 +204,9 @@ TileMesh.prototype.changeSequenceLayers = function changeSequenceLayers(sequence | |||
|
|||
TileMesh.prototype.getCoordsForLayer = function getCoordsForLayer(layer) { | |||
if (layer.protocol.indexOf('wmts') == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layer.source.protocol ?
src/Core/View.js
Outdated
@@ -177,12 +184,15 @@ function _preprocessLayer(view, layer, provider, parentLayer) { | |||
|
|||
// probably not the best place to do this | |||
if (layer.type == 'color') { | |||
layer.fx = layer.fx || 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not a defineLayerProperty as for other properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defineLayerProperty
is a bad practice imho, and achieves nothing besides reducing a little the duplicated code, executing a callback in really rare usecases and emitting events on properties change. But I wouldn't change it here, and in the meantime keep this property declaration as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good idea. The introduction of a Source
object (kind of like OpenLayers ?) is a good step towards decluttering providers. Could you add a more accurate description (maybe documentation like the current Provider
interface ?) to this object ?
However I don't really like a few things:
- the fetching in
geoFileSource
: no operation like should happen in aSource
- the
convert
method inlayer
: what about your initials thoughts withsource, processing, style
only ?
src/Parser/textureConverter.js
Outdated
}; | ||
|
||
export default { | ||
textureColorLayer(texture, extent, layer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't call this textureColorLayer. Why not have two methods, color
and elevation
, which gives textureConverter.color
and textureConverter.elevation
calls.
Also by introducing this you could drop the getColor/XBilTextureByUrl
in OGCWebServiceHelper
which have nothing to do with OGC.
src/Provider/Fetcher.js
Outdated
@@ -1,14 +1,24 @@ | |||
import { TextureLoader } from 'three'; | |||
import { TextureLoader, DataTexture, AlphaFormat, FloatType, LinearFilter } from 'three'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion: we should always import * as THREE
, I don't get the appeal behind selecting what we are importing.
checkResponse(response); | ||
return response.arrayBuffer(); | ||
arrayBuffer, | ||
textureFloat(url, options = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part should be in the elevationTexture
part imho. Let's keep the Fetcher
simple.
src/Core/Scheduler/Scheduler.js
Outdated
if (typeof (provider.preprocessDataLayer) !== 'function') { | ||
throw new Error(`Can't add provider for ${protocol}: missing a preprocessDataLayer function.`); | ||
} | ||
// if (typeof (provider.preprocessDataLayer) !== 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/Core/View.js
Outdated
|
||
// temp | ||
// devrait etre supprime et placer dans source | ||
if (provider && !layer.source) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, a provider shouldn't be the one defining the limit.
@@ -166,6 +174,15 @@ function _preprocessLayer(view, layer, provider, parentLayer) { | |||
if (!(providerPreprocessing && providerPreprocessing.then)) { | |||
providerPreprocessing = Promise.resolve(); | |||
} | |||
} else if (layer.source) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like having this here, as much as I don't like having all other things below (conditions on type of layer). I know though that you hope to move it to the layer itself, so I'm ok with this here for now.
src/Core/View.js
Outdated
@@ -177,12 +184,15 @@ function _preprocessLayer(view, layer, provider, parentLayer) { | |||
|
|||
// probably not the best place to do this | |||
if (layer.type == 'color') { | |||
layer.fx = layer.fx || 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defineLayerProperty
is a bad practice imho, and achieves nothing besides reducing a little the duplicated code, executing a callback in really rare usecases and emitting events on properties change. But I wouldn't change it here, and in the meantime keep this property declaration as it is.
I'm all for refactoring this part, and the chosen solution looks similar to what was previously discussed. Random notes:
The last point is important. For instance, if this PR doesn't help implement vector-tiles support easily, then something is wrong. |
86a4f54
to
a69dd40
Compare
Sounds like the way to go! |
3506ba2
to
7592921
Compare
1a22624
to
24adf87
Compare
I tested the examples, here's what I saw: |
@zarov all examples are fixed New change:
|
d6fcdb4
to
dd1006a
Compare
src/Source/Source.js
Outdated
*/ | ||
class Source { | ||
/** | ||
* @param {sourceParams} source object to set source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove the @class
declaration above, and write a @constructor
here, to avoid duplication in the generated page of the documentation.
You should also write an example of declaring a random Source. Best would be to have it for all Sources files.
bcb8f07
to
15c1612
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments on the Sources files !
src/Source/FileSource.js
Outdated
*/ | ||
constructor(source, crsOut) { | ||
super(source); | ||
if (!source.url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to repeat this as it is already been checked in Source
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
src/Source/FileSource.js
Outdated
throw new Error('source.url is required in FileSource'); | ||
} | ||
|
||
if (!source.projection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should specify in the documentation above that the projection is mandatory for this type of Source. This check can also be moved before calling super(source)
.
* @param {Extent} extent extent to convert in url | ||
* @return {string} url from extent | ||
*/ | ||
// eslint-disable-next-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a problem I encountered as well, there is three solutions:
eslint-disable-next-line
- declaring this method as
static
:static urlFromExtent(extent)
, that can still be called withthis.urlFromExtent(extent)
orsource.urlFromExtent(extent)
- removing the
class-method-use-this
eslint check from the configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, there are errors lint too for jsdoc
src/Source/StaticSource.js
Outdated
constructor(source) { | ||
super(source); | ||
|
||
if (!source.extent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, you can move this check before calling the parent constructor and specify in the documentation that the extent
is required here.
src/Source/WFSSource.js
Outdated
* @param {Object} [source.zoom] | ||
* @param {number} [source.zoom.min] layer's zoom minimum | ||
* @param {number} [source.zoom.max] layer's zoom maximum | ||
* @param {string} [source.zoom.max] layer's zoom maximum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean something else ?
src/Source/WFSSource.js
Outdated
*/ | ||
constructor(source) { | ||
super(source); | ||
if (!source.typeName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, move the super
below
src/Source/WMSSource.js
Outdated
} | ||
} | ||
|
||
let crsPropName = 'SRS'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not directly const crsPropName = (this.version === '1.3.0') ? 'CRS' : 'SRS';
?
src/Source/WMTSSource.js
Outdated
|
||
/** | ||
* Options to wtms protocol | ||
* @typedef {Object} OptionsWmts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be detailed ?
c8cecb8
to
228116e
Compare
Add new object source: - Source have the properties to fetch the data to display - Remove all source abstractions from provider
@zarov PR updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK let's validate this, I think I didn't see any problem.
For fixing your failing test, either remove it, or install a polyfill for URL
(like this one https://github.com/webcomponents/URL) as it is not a component supported in nodejs.
It is even occurring because the |
Description
add
Source
in layer : all the parameters to get the data from a sourceadd
convert
in layer : fonction to convert data from source to layer's elementsThe layer does
The provider does
Motivation
sources
andconverters/parsers
from providers and use them for other layers